package mta.util;

import org.apache.commons.io.FilenameUtils;

import java.io.File;

public class FilesystemUtil {

    static public void cleanDirectoryFromCsv(String path) {
        deleteDir(new File(path));
    }

    static private void deleteDir(File file) {
        if (file.isDirectory()) {
            File fileList[] = file.listFiles();
            for (File subfile : fileList) {
                deleteDir(subfile);
            }
        }

        String ext = FilenameUtils.getExtension(file.getName());
        if (file.isFile() && ext.equals("csv")) {
            if (!file.delete()) {
                System.out.println("Cant delete " + file);
            }
        }
    }


}
